package com.group01.community.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.group01.community.entity.SysDictType;
import com.group01.community.mapper.SysDictTypeMapper;
import com.group01.community.service.SysDictTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 字典类型表 服务实现类
 * </p>
 *
 * @author guoyuan
 * @since 2025-05-01
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    @Override
    public IPage<SysDictType> selectFuzzy(SysDictType sysDictType, Long current, Long size) {
        String[] createTime = null;
        if ("".equals(sysDictType.getCreateTime()) || sysDictType.getCreateTime() == null) {
            createTime = new String[]{"", ""};
        } else {
            createTime = sysDictType.getCreateTime().split(",");
        }
        return sysDictTypeMapper.selectFuzzy(sysDictType, createTime[0], createTime[1], new Page<>(current, size));
    }

    @Override
    public IPage<SysDictType> selectPage(Long current, Long size) {
        return sysDictTypeMapper.selectPage(new Page<>(current, size));
    }
}
